import os
#for循环左下三角形
def form1_for():
    for i in range(1,10):
        for j in range(1, i+1):
            print("{}*{}={:<4}".format(j,i,j*i),end=" ")
        print()
#for循环右下
def form2_for():
    for i in range(1, 10):
        for k in range(1, 10 - i):
            print(end="         ")
        for j in range(1, i + 1):
            print("{}*{}={:<4}".format (i, j, i * j), end=" ")
        print(" ")
#for循环左上三角形
def form3_for():
    for i in range(1,10):
        for j in range(i, 10):
            print("{}*{}={:<4}".format(j,i,j*i),end=" ")
        print()

#for循环右上
def form4_for():
    for i in range(1, 10):
        for k in range(1, i):
            print(end="         ")
        for j in range(i, 10):
            print("{}*{}={:<4}".format(i, j, i * j), end=" ")
        print("")

#while循环左下三角形
def form1_while():
    i=1
    while i<10:
        j=1
        while j<i+1:
            print("{}*{}={:<4}".format(j, i, j * i), end=" ")
            j+=1
        print()
        i+=1
#while循环右下
def form2_while():
    i=1
    while i<10:
        k=1
        while k< 10 - i:
            print(end="         ")
            k+=1
        j=1
        while j<i+1:
            print("{}*{}={:<4}".format(j, i, j * i), end=" ")
            j+=1
        print()
        i+=1

#while循环左上三角形
def form3_while():
    i=1
    while i<=9:
        j=i
        while j<10:
            print("{}*{}={:<4}".format(j, i, j * i), end=" ")
            j+=1
        print()
        i+=1

#while循环右上
def form4_while():
    i=1
    while i<10:
        k=1
        while k< i:
            print(end="         ")
            k+=1
        j=i
        while j<10:
            print("{}*{}={:<4}".format(j, i, j * i), end=" ")
            j+=1
        print()
        i+=1
def run_for():
    print("========这是for循环实现99乘法表实例========")
    print("========这是for循环左下99乘法表实例========")
    form1_for()
    print("="*81)
    print("========这是for循环右下99乘法表实例========")
    form2_for()
    print("="*81)
    print("========这是for循环左上99乘法表实例========")
    form3_for()
    print("="*81)
    print("========这是for循环右上99乘法表实例========")
    form4_for()
    print("="*81)

def run_while():
    print("========这是while循环实现99乘法表实例========")
    print("========这是while循环左下99乘法表实例========")
    form1_while()
    print("="*81)
    print("========这是while循环右下99乘法表实例========")
    form2_while()
    print("="*81)
    print("========这是while循环左上99乘法表实例========")
    form3_while()
    print("="*81)
    print("========这是while循环右上99乘法表实例========")
    form4_while()
    print("="*81)


if __name__ == "__main__":
    run_for()#for循环99乘法表实例
    run_while()#while循环99乘法表实例
    os.system("pause")